package uniLearn.data;

import java.util.Date;

public class SubmitAssignment {
	//define
	public static final int NAME_MAX_LENGTH = 50;
	public static final int FILENAME_MAX_LENGTH = 50;
	
	//variable
	private int acId;
	private String submitBy;
	private int agId;
	private String fileName;
	private Date submitTime;
	private SubmitStatus submitStatus;
	
	//constructor
	public SubmitAssignment(int acId, String submitBy, int agId) {
		if(submitBy.isEmpty() || submitBy.length() > Users.NAME_MAX_LENGTH) {
			//error
			return;
		}
		
		this.acId = acId;
		this.agId = agId;
	}
	
	public SubmitAssignment(int acId, String submitBy) {
		this(acId, submitBy, -1);
	}

	//get method
	public int getAcId() {
		return acId;
	}

	public String getSubmitBy() {
		return submitBy;
	}

	public int getAgId() {
		return agId;
	}

	public SubmitStatus getSubmitStatus() {
		return submitStatus;
	}

	public void setSubmitStatus(SubmitStatus submitStatus) {
		this.submitStatus = submitStatus;
	}

	public String getFileName() {
		return fileName;
	}

	public Date getSubmitTime() {
		return submitTime;
	}

	//set method
	public void setFileName(String fileName) {
		if(fileName.length() > FILENAME_MAX_LENGTH) {
			//error
			return;
		}
		this.fileName = fileName;
	}

	public void setSubmitTime(Date submitTime) {
		this.submitTime = submitTime;
	}

	//override
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + acId;
		result = prime * result + agId;
		result = prime * result
				+ ((fileName == null) ? 0 : fileName.hashCode());
		result = prime * result
				+ ((submitBy == null) ? 0 : submitBy.hashCode());
		result = prime * result
				+ ((submitTime == null) ? 0 : submitTime.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SubmitAssignment other = (SubmitAssignment) obj;
		if (acId != other.acId)
			return false;
		if (agId != other.agId)
			return false;
		if (fileName == null) {
			if (other.fileName != null)
				return false;
		} else if (!fileName.equals(other.fileName))
			return false;
		if (submitBy == null) {
			if (other.submitBy != null)
				return false;
		} else if (!submitBy.equals(other.submitBy))
			return false;
		if (submitTime == null) {
			if (other.submitTime != null)
				return false;
		} else if (!submitTime.equals(other.submitTime))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "SubmitAssignment [acId=" + acId + ", submitBy=" + submitBy
				+ ", agId=" + agId + ", fileName=" + fileName + ", submitTime="
				+ submitTime + "]";
	}
	
	
}
